Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Creating a Viewer

You can create a viewer object by calling the Q3ViewerNew function. You pass Q3ViewerNew a pointer to the window in which you want the viewer to appear, the rectangle that is to contain the viewer pane, and a selector indicating which viewer features to enable. Q3ViewerNew returns a reference to a viewer object. Listing 14 illustrates one way to call Q3ViewerNew . The function MyCreateViewer defined in Listing 14 creates a viewer pane that occupies the entire content region of the window whose address is passed to it as a parameter.

Listing 14 Creating a viewer object

TQ3ViewerObject MyCreateViewer (WindowPtr myWindow)
{
    TQ3ViewerObject         myViewer;
    Rect                    myRect;
    /*Get rectangle enclosing the window's content region.*/
    myRect = myWindow->portRect;
    if (EmptyRect(&myRect))             /*make sure we got a nonempty rect*/
        goto bail;

    /*Create a new viewer object in entire content region.*/
    myViewer = Q3ViewerNew((CGrafPtr)myWindow, &myRect, kQ3ViewerDefault);
    if (myViewer == NULL)
        goto bail;

    return(myViewer);                   /*return new viewer object*/

bail:
    /*If any of the above failed, return an empty viewer object.*/
    return(NULL);
}

The third parameter to the call to Q3ViewerNew is a set of viewer flags that specify information about the appearance and behavior of the new viewer object. In Listing 14 , the viewer flag parameter is set to the value kQ3ViewerDefault , indicating that the default values of the viewer flags are to be used. See "Viewer Flags" for a complete description of the available viewer flags.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |